import axios from 'axios';
// let baseURLUpload = 'https://saas-prod.obs.cn-east-3.myhuaweicloud.com';
let baseURLUpload =
  process.env.VUE_APP_MODE === 'pro'
    ? 'https://saas-prod.obs.cn-east-3.myhuaweicloud.com/'
    : 'https://saas-dormitory.obs.cn-east-3.myhuaweicloud.com/';

const serviceUpload = axios.create({
  baseURL: baseURLUpload,
  headers: { Accept: '*/*' },
  widthCredentials: false,
  transformRequest: [
    function (data, headers) {
      if (data instanceof FormData) {
        return data;
      }
    }
  ]
});

serviceUpload.interceptors.request.use(
  config => {
    return config;
  },
  error => {
    return Promise.reject(error);
  }
);

serviceUpload.interceptors.response.use(
  res => {
    return res;
  },
  error => {
    return Promise.reject(error);
  }
);
const requestUpload = optionObj => serviceUpload(optionObj);
export default requestUpload;
